import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'

Vue.use(VueRouter)

//引入静态组件 【使得首屏加载速度变快】 
import Layout from '@/views/layout/Layout.vue';

const routes: Array<RouteConfig> = [
  {
    path: '/',
    redirect: '/home'
  },
  /* 首页 */
  {
    path: '/home',
    component: Layout,
    redirect: '/home/goods', //重定向到商品
    children: [
      {
        path: '/home/goods',
        component: () => import('@/views/goods/Goods.vue')
      },
      {
        path: '/home/comment',
        component: () => import('@/views/comment/Comment.vue')
      },
      {
        path: '/home/shop',
        component: () => import('@/views/shop/Shop.vue')
      },
    ]
  },
  /* 详情页 */
  {
    path: '/detail',
    component: () => import('@/views/detail/Detail.vue')
  },
  /* 错误路由 */
  {
    path: '*',
    component: () => import('@/views/error-404/Error404.vue')
  }

]

const router = new VueRouter({
  routes
})

export default router
